define(['../../../../../js/lib/other/sweet-alert'],function() {
    return ['$scope','$location', '$interval','$timeout','$routeParams','bizProxy', function($scope,$location,$interval,$timeout,$routeParams,bizProxy) {
		$scope.$emit("top-show",'true');//顶部显示
    	$scope.$emit('menuTypeLight','mine'); 	//控制底部menu高亮
    	$scope.$emit('bub-menu','true'); 	//隐藏底部menu
    	$scope.$emit('flag-tag','46');//显示底部文字
    	
    	if($routeParams.flag != "" && $routeParams.flag != null){
    		queryLoanApplyOutline($routeParams.flag);
    	}
    	
    	document.querySelector('#my_loan_check_pd .main .img_show').style.backgroundImage = 'url(http://wx.winhc.cn/showImageById.ajax?imageName='+$routeParams.flag+'.jpg)';
    	
    	//调用代理接口获取数据
    	function queryLoanApplyOutline(applyId){
    		var headerInfo = {},bizInfo = {};
        	headerInfo.pageNum = '';
        	headerInfo.pageSize = '';
        	headerInfo.sessionId = transData.sessionId;
        	
        	bizInfo.applyId = applyId;
    		$scope.$emit("loadingChangeNav",true);
    		bizProxy.queryProxyBizData("queryLoanApplyOutline",headerInfo,bizInfo,
    				function(tempData){//SUCCESS
		    			if(tempData.body != "" && tempData.body != null && tempData.body != "[]"){
							$timeout(function(){
								$scope.$emit("loadingChangeNav",false);
								var loanData = JSON.parse(tempData.body);
								$scope.reason = loanData.reason;
								$scope.inviteCode = loanData.inviteCode;
						    	$scope.applicantType = loanData.applyUserType;
						    	$scope.applyName = loanData.applyUserName;
						    	$scope.idType = loanData.idType;
						    	$scope.documentsNo = loanData.idNo;
						    	$scope.loanAmount = loanData.loanAmount;
						    	$scope.creditorType = loanData.debtType;
						    	$scope.caseNo = loanData.caseNo;
						    	$scope.caseQuan = loanData.caseAmount;
		//				    	$scope.caseName = loanData.caseTopic;
						    	
						    	$scope.applicantName = (loanData.applyUserType == '1')?"自然人":(loanData.applyUserType == '2')?"法人":(loanData.applyUserType == '3')?"其他非法人组织":"";
						    	$scope.idName = (loanData.idType == "1")?"身份证":(loanData.idType == "2")?"营业执照":(loanData.idType == "2")?"组织机构代码":"";
						    	$scope.creditorName = (loanData.debtType == "1")?"金融债权":(loanData.debtType == "2")?"企业债权":(loanData.debtType == "3")?"民间借贷":(loanData.debtType == "4")?"其它":"";
							},0);
						}else{
							$scope.$emit("loadingChangeNav",false);
							$scope.$emit("promptAlertMsg","未查找到相关数据");
							$scope.$emit("showCollect",true);
							$timeout(function(){
								$scope.$emit("showCollect",false);
								history.back();
							},transData.promptTime);
						}
		    		},function(data){
		    			if(data != ""){//FAIL
		    				$scope.$emit("loadingChangeNav",false);
							if(data.errorCode == ERROR_CODE.noLogin){
								FIREFLY("", data.errorMsg,"",function(){
										//调用退出登录
										transData.mobileNo = "";
		    							transData.password = "";
		    							transData.sessionId = "";
		    							transData.userType = "";
		    							resultData.loginUserData = "";
		    							$timeout(function(){
		    								$scope.$emit("goNext","/mine");
		    							},0);
								});
							}else{
								$scope.$emit("promptAlertMsg", data.errorMsg);
								$scope.$emit("showCollect",true);
								$timeout(function(){
									$scope.$emit("showCollect",false);
								},transData.promptTime);
							}
		    			}else{
		    				$scope.$emit('loadingChangeNav', false);
		    				$scope.$emit("promptAlertMsg","连接超时");
		    				$scope.$emit("showCollect",true);
		    				$timeout(function(){
		    					$scope.$emit("showCollect",false);
		    					history.back();
		    				},transData.promptTime);
		    			}
		    		});
    	}
    	
        $scope.$apply();
    }];
});